/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package admin.Controller;

import Exception.SystemException;
import admin.BusinessLogic.BusinessLogic;
import admin_gui.AdminGUI;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author WEN
 */
public class LoginController {

    private String userID;
    private String pwd;
    private AdminGUI adminGUI;
    private BusinessLogic businesslogic;
 //   private Admin_Manage adminManage;
    public LoginController(AdminGUI ag){
       // adminGUI = new AdminGUI();
        adminGUI = ag;
        try {
            businesslogic = new BusinessLogic();
        } catch (FileNotFoundException ex) {
            Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void loginControl(String name, String password) {
        userID = name;
        pwd = password;
        if (businesslogic.loginLogical(userID, pwd)) {
                adminGUI.ManageScreen();
        } else {
            JOptionPane.showMessageDialog(null, "Sorry! Password is no correct.",
                    "Error", JOptionPane.ERROR_MESSAGE);
        }
    }
}
